/**
 *	The NeuroCoSA Toolkit
 *	Copyright (C) 2003-6 Stuart Meikle.
 *
 *	This is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU Lesser General Public
 *	License as published by the Free Software Foundation; either
 *	version 2.1 of the License, or (at your option) any later version.
 *
 *	This library is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *	Lesser General Public License for more details.
 *
 * @author	Stuart Meikle
 * @version	2006-halloween(mk2)
 * @license	LGPL
 */

package org.stumeikle.NeuroCoSA;
import java.util.*;

/** Common base class for lobe and filter, brain and nucleus. 
 *  Indicative of an information processing unit
 */
public	class	DPU implements Comparable
{
    static int		iDPUCount=0;
    double		iDepth;
    String		iName;
    LinkedList<DPU>	iInputs;
    DataBlock		iOutput;/** the output. maybe we could call this 'axon' ;-) 
				 *  the DPU outputs are fixed. inputs are flexbile 
				 */


    public DPU()
    {
	constructor();
    }
    public DPU( String n )
    {
	constructor();
	iName =n;
    }
    public	String		getName()
    { return iName; }

    public	void		setName(String s)
    { iName = s; }

    private	void		constructor()
    {
	iOutput=null;
	iInputs= new LinkedList<DPU>();
	iDepth=-1.0;
	iName = new String("DPU" + (iDPUCount++) );
    }

    public	void		update(){} /** update . no inputs needed */
    public	DataBlock	getOutput()
    {
	return iOutput;
    }
    protected	void		setOutput(DataBlock db) 
    {   iOutput=db; }

    public	void		addInput( DPU d )
    {
	iInputs.add(d); 
    }

    public	LinkedList<DPU>	getInputs()
    {
	return iInputs;
    }

    public	void		setDepth( double d )
    {   iDepth = d; }

    public	double		getDepth()
    { return iDepth; }

    //needed for sorting
    public	int		compareTo( Object o )
    {
	DPU	d = (DPU) o;

	if (getDepth() < d.getDepth())	return -1;
	if (getDepth() > d.getDepth()) 	return 1;

	return 0;
    }

    public	void		getReady() 
    {}
}
